Unify border-spacing handling
authorMatthias Clasen <mclasen@redhat.com>
Thu, 28 Jan 2021 03:21:02 +0000 (22:21 -0500)
committerMatthias Clasen <mclasen@redhat.com>
Thu, 28 Jan 2021 17:27:07 +0000 (12:27 -0500)
Avoid using GtkStyleContext unnecessarily, just go
to the css node directly.

gtk/gtkboxlayout.c
gtk/gtkcenterlayout.c
gtk/gtkgridlayout.c

index cb9bf024a03c1da35ec76fd22e6239bc133eff43..744f6a7f46affc561d5817e12f979f0ee3a3ad69 100644 (file)
@@ -25,9 +25,9 @@
 #include "gtkorientable.h"
 #include "gtkprivate.h"
 #include "gtksizerequest.h"
-#include "gtkstylecontextprivate.h"
 #include "gtktypebuiltins.h"
 #include "gtkwidgetprivate.h"
+#include "gtkcssnodeprivate.h"
 
 /**
  * SECTION:gtkboxlayout
index b2dee1db0d11a2c8cb5f258365275c7a87b5c046..c5264ddaf6eeb524fe894cc8c3e0413e46526234 100644 (file)
@@ -23,8 +23,8 @@
 #include "gtklayoutchild.h"
 #include "gtkprivate.h"
 #include "gtksizerequest.h"
-#include "gtkstylecontextprivate.h"
 #include "gtkwidgetprivate.h"
+#include "gtkcssnodeprivate.h"
 
 /**
  * SECTION:gtkcenterlayout
@@ -58,12 +58,13 @@ G_DEFINE_TYPE (GtkCenterLayout, gtk_center_layout, GTK_TYPE_LAYOUT_MANAGER)
 
 static int
 get_spacing (GtkCenterLayout *self,
-             GtkStyleContext *style_context)
+             GtkCssNode      *node)
 {
+  GtkCssStyle *style = gtk_css_node_get_style (node);
   GtkCssValue *border_spacing;
   int css_spacing;
 
-  border_spacing = _gtk_style_context_peek_property (style_context, GTK_CSS_PROPERTY_BORDER_SPACING);
+  border_spacing = style->size->border_spacing;
   if (self->orientation == GTK_ORIENTATION_HORIZONTAL)
     css_spacing = _gtk_css_position_value_get_x (border_spacing, 100);
   else
@@ -226,7 +227,7 @@ gtk_center_layout_measure_orientation (GtkCenterLayout *self,
   int spacing;
   int i;
 
-  spacing = get_spacing (self, _gtk_widget_get_style_context (widget));
+  spacing = get_spacing (self, gtk_widget_get_css_node (widget));
 
   for (i = 0; i < 3; i ++)
     {
@@ -386,7 +387,7 @@ gtk_center_layout_allocate (GtkLayoutManager *layout_manager,
   int i;
   int spacing;
 
-  spacing = get_spacing (self, _gtk_widget_get_style_context (widget));
+  spacing = get_spacing (self, gtk_widget_get_css_node (widget));
 
   if (self->orientation == GTK_ORIENTATION_HORIZONTAL)
     {
index 77cc7a4e386169371bd5065246f3d3a4147c58d6..3d0178768010a281f45ec8c58e4ca97838afe340 100644 (file)
@@ -51,8 +51,8 @@
 #include "gtkorientable.h"
 #include "gtkprivate.h"
 #include "gtksizerequest.h"
-#include "gtkstylecontextprivate.h"
 #include "gtkwidgetprivate.h"
+#include "gtkcssnodeprivate.h"
 
 /* {{{ GtkGridLayoutChild */
 typedef struct {